<?php
class UserDataModel extends CI_Model {
	function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
	
	function inserUserData($userData){
		$sql = "INSERT INTO eq_user_data (user_id, trust, respect, care, commitment, financial_support, domestric_support, intimacy, physical_appearance, fun_time_together, best_friend_talk, spiritual_intimacy, conflict_resolution, is_present, create_date, update_date) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		if($this->db->query($sql, $userData)){
			return $this->db->insert_id();
		}else{
			return false;
		}
	}
	function updateUserData($userData){
		$sql = "UPDATE eq_user_data SET trust = ?, respect = ?, care = ?, commitment = ?, financial_support = ?, domestric_support = ?, intimacy = ?, physical_appearance = ?, fun_time_together = ?, best_friend_talk = ?, spiritual_intimacy = ?, conflict_resolution = ?, update_date = ? WHERE id = ?";
		if($this->db->query($sql, $userData)){
			return $this->db->insert_id();
		}else{
			return false;
		}
	}
	
	function getUserData($userId, $isPresent){
		$query = $this->db->get_where('eq_user_data', array('user_id' => $userId, 'is_present' =>$isPresent));
		$userData = $query->result();
		if(count($userData) > 0){
			return $userData[0];
		}else{
			return null;
		}
	}
	
}